﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Xejen.Common.Winform.Test
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);


        }

        private async void button2_Click(object sender, EventArgs e)
        {
            //var data = @"<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
            //  <soap:Header>
            //    <LoginSoapHeader xmlns=""http://tempuri.org/"">
            //      <EquUserID>admin</EquUserID>
            //      <EquPassword>admin123</EquPassword>
            //    </LoginSoapHeader>
            //  </soap:Header>
            //  <soap:Body>
            //    <HelloWorld xmlns=""http://tempuri.org/"">
            //      <body>
            //        <EquipmentCode>${CCD_Ca_ofRetain1}</EquipmentCode>
            //      </body>
            //    </HelloWorld>
            //  </soap:Body>
            //</soap:Envelope>";

            //var data = @"
            //    {
            //        ""name"": ""John"",
            //        ""age"": 30,
            //        ""isStudent"": false,
            //        ""address"": null,
            //        ""courses"": [""Math"", ""Science""]
            //    }
            //";


            var data = @"{""TaskId"":4524, ""Address"":{""HttpConfig"":{""ContentType"":""text/xml"", ""Encoding"":{""BodyName"":""utf-8"", ""EncodingName"":""Unicode (UTF-8)"", ""HeaderName"":""utf-8"", ""WebName"":""utf-8"", ""WindowsCodePage"":1200, ""IsBrowserDisplay"":true, ""IsBrowserSave"":true, ""IsMailNewsDisplay"":true, ""IsMailNewsSave"":true, ""IsSingleByte"":false, ""EncoderFallback"":{""DefaultString"":""�"", ""MaxCharCount"":1}, ""DecoderFallback"":{""DefaultString"":""�"", ""MaxCharCount"":1}, ""IsReadOnly"":true, ""CodePage"":65001}, ""EncodingName"":""UTF-8"", ""UserName"":""SUP_JCC01_CL01"", ""Password"":""CA@JCmesCL01"", ""Enable"":true, ""Timeout"":50000, ""HeartbeatConfig"":{""Enable"":true, ""Interval"":4567}, ""JsonSerializerOptions"":{""Converters"":[], ""TypeInfoResolver"":{""Modifiers"":[]}, ""TypeInfoResolverChain"":[], ""AllowTrailingCommas"":false, ""DefaultBufferSize"":16384, ""Encoder"":{""MaxOutputCharactersPerInputCharacter"":6}, ""IgnoreNullValues"":false, ""DefaultIgnoreCondition"":""Never"", ""NumberHandling"":""Strict"", ""PreferredObjectCreationHandling"":""Replace"", ""IgnoreReadOnlyProperties"":false, ""IgnoreReadOnlyFields"":false, ""IncludeFields"":false, ""MaxDepth"":0, ""PropertyNamingPolicy"":""System.Text.Json.JsonCamelCaseNamingPolicy"", ""PropertyNameCaseInsensitive"":true, ""ReadCommentHandling"":""Disallow"", ""UnknownTypeHandling"":""JsonElement"", ""UnmappedMemberHandling"":""Skip"", ""WriteIndented"":false, ""IsReadOnly"":true}, ""LogVerbosity"":""Normal""}, ""RequestAddress"":{""Value"":{""RequestUri"":""http://192.168.3.164:112/WebService1.asmx?op=HelloWorld""}, ""HasValue"":true}, ""Headers"":[""Username"",""Password""]}, ""TimeOut"":50000, ""Response"":{""Code"":200, ""IsSuccess"":true, ""ReturnData"":""<?xml version=\""1.0\"" encoding=\""utf-8\""?><soap:Envelope xmlns:soap=\""http://schemas.xmlsoap.org/soap/envelope/\"" xmlns:xsi=\""http://www.w3.org/2001/XMLSchema-instance\"" xmlns:xsd=\""http://www.w3.org/2001/XMLSchema\""><soap:Body><HelloWorldResponse xmlns=\""http://tempuri.org/\""><HelloWorldResult><Code>-1</Code><Msg>用户验证通过！</Msg></HelloWorldResult></HelloWorldResponse></soap:Body></soap:Envelope>""}}";


            //var data = "土木工程魂牵梦萦32大声道";

            Xejen.Editor.DataVisualizeForm form = new Editor.DataVisualizeForm(data, language: "XML", readWriteType: Editor.ReadWriteType.Write);
            if (form.ShowDialog() == DialogResult.OK)
            {
                var value = await form.GetDataAsync();
            }
        }
    }
}
